﻿Imports System.IO
Module Main
    'Decalrations:
    Public currentPath As String
    Public pathClean As String
    Public pathArray() As String
    Public command As String
    Public commandArray() As String
    Sub Main()
        Console.Title = "OpenCLI - Open Source CLI"
        Startup.startupBanner()
        currentPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)
        pathArray = currentPath.Split("\")
        pathClean = pathArray(UBound(pathArray))
        If pathClean = "" Then
            pathClean = "\"
        End If

        Do
            Try
                Console.ForegroundColor = ConsoleColor.White
                Console.Write(Environment.UserName & "@" & Environment.MachineName & " " & pathClean & ">")
                Console.ResetColor()
                command = Console.ReadLine()
                commandArray = command.Split(" ")
                Select Case commandArray(0)
                    Case Is = "shutdown"
                        OpenCLI.System.EnvironmentHandler.Environment._construct(command, currentPath)
                    Case Is = "reboot"
                        OpenCLI.System.EnvironmentHandler.Environment._construct(command, currentPath)
                    Case Is = "logoff"
                        OpenCLI.System.EnvironmentHandler.Environment._construct(command, currentPath)
                    Case Is = "cd"
                        Core.cd(command)
                    Case Is = "current"
                        Core.current()
                    Case Is = "ls"
                        OpenCLI.System.IOHandler.IOHandler._construct(command, currentPath)
                    Case Else
                        Errors.notRecognized()
                End Select
            Catch ex As Exception
                MsgBox(ex.Message.ToString, MsgBoxStyle.Critical)
                End
            End Try
        Loop
    End Sub

End Module
